package org.osomit.sacct.server;

import org.osomit.sacct.remoting.Listener;

/**
 * 
 * @author Jian Fang (John.Jian.Fang@gmail.com)
 *
 * Date: Jul 5, 2009
 *
 */
public class AccountServerShutdownHook extends Thread {

    private Listener listener;

    private Integer count = 1;

    public Listener getListener() {
        return listener;
    }

    public void setListener(Listener listener) {
        this.listener = listener;
    }

    public void run() {

        synchronized (this.count) {
            
            if (this.listener != null && count == 1) {
                this.count++;


                this.listener.stop();
            }
        }

    }
}
